package com.example.demo.controller;


import com.example.demo.model.Ucmana;
import com.example.demo.service.IUcmanaService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/*
administrator 张少婷
 */
@Api(tags = "用车信息")
@RestController
@RequestMapping("/swagger9")
public class UcmanaController {
        @Autowired
        private IUcmanaService ucmanaService;
        @CrossOrigin
        @ApiOperation(value="用车信息的添加方法")
        @PostMapping("/insertUcmana")
        public int insertUcmana(@RequestBody Ucmana ucmana){
            System.out.println("进入添加用车信息接口");
            return ucmanaService.insertUcmana(ucmana);
        }
       @PostMapping("/getAllUcmana")
    public List<Ucmana> getAllUcmana(@RequestBody Ucmana ucmana){
          System.out.println("进入查询方法");
          List<Ucmana> listUcmana=ucmanaService.getAllUcmana(ucmana);
          return listUcmana;
       }
       @PostMapping("/editUcmana")
    public int EditUcmana(@RequestBody Ucmana ucmana){
            System.out.println("添加修改方法");
            return ucmanaService.updateUcmana(ucmana);
       }
       @GetMapping("/delUcmana")
    public int Delete(int ygid){
            System.out.println("进入删除方法");
            int returnValues=0;
            if(ygid!=0){
                Ucmana ucmana=new Ucmana();
                ucmana.setYgid(ygid);
                returnValues =ucmanaService.deleteUcmana(ucmana);
            }
            return returnValues;
       }
       @GetMapping("/getOneUcmana")
    public Ucmana getAllUcmana(int ygid){
            Ucmana ucmana=new Ucmana();
            System.out.println("进入单条查询方法");
            if(ygid!=0){
                Ucmana ucmana1=new Ucmana();
                ucmana1.setYgid(ygid);
                ucmana=ucmanaService.getUcmana(ucmana1);
                System.out.println("返回的数据集合:"+ucmana.getYgid());
            }
            return ucmana;
       }
    }

